<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>

    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    
    <script type="text/babel">
        // 创建组件
        class Weather extends React.Component {
            // 初始化状态
            state = {isHot:true}

            render() {
                // 读取状态
                const {isHot} = this.state 
                return <h1 onClick={this.changeWeather}>今天天气{isHot ? '炎热' :'凉爽' }</h1>
            }

            // 自定义方法 -- 赋值语句+箭头函数（中的this指向上下文中的this）
            changeWeather = ()=>{
                this.setState({isHot:!this.state.isHot})
            }
        }
        ReactDOM.render(<Weather/>,document.querySelector('#app'))
    </script>
</body>
</html>
